"""
生成器：语法升级版本的迭代器
"""


def fib(num):
    a, b = 0, 1
    for _ in range(num):
        a, b = b, a + b
        yield a


fib_iter = fib(20)
try:
    while True:
        print(next(fib_iter))
except StopIteration:
    pass
# for value in fib(20):
#     print(value)
